//
//  ZJOrganizationSelectView.m
//  LovingPartyBuilding
//
//  Created by ZJ on 2017/5/5.
//  Copyright © 2017年 刘应平. All rights reserved.
//

#import "ZJOrganizationSelectView.h"

@interface ZJOrganizationSelectView ()<UITextFieldDelegate>
/** 图片 */
@property (nonatomic, strong) UIImageView *imageView;
@end

@implementation ZJOrganizationSelectView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.layer.cornerRadius = 4 * [UIScreen zj_screenWScale];
        self.layer.borderColor = [UIColor zj_colorWithHexString:@"ededed"].CGColor;
        self.layer.borderWidth = 1;
        self.select = NO;
        
        [self addSubview:self.textField];
        [self addSubview:self.imageView];
        
        self.imageView.sd_layout
        .topSpaceToView(self, 0)
        .bottomSpaceToView(self, 0)
        .rightSpaceToView(self, 15 * [UIScreen zj_screenWScale])
        .widthIs(10 * [UIScreen zj_screenWScale]);
        
        self.textField.sd_layout
        .topSpaceToView(self, 0)
        .bottomSpaceToView(self, 0)
        .leftSpaceToView(self, 15 * [UIScreen zj_screenWScale])
        .rightSpaceToView(self.imageView, 15 * [UIScreen zj_screenWScale]);
        
        
    }
    return self;
}

#pragma mark - 点击事件
- (void)action_tapGest:(UITextField *)textField{
    if (self.delegate) {
        [self.delegate ZJOrganizationSelectViewDelegate_SelectView:self textFieldText:textField.text];
    }
}



#pragma mark - Setter
- (BOOL)textFieldShouldReturn:(UITextField *)textField {
    
    [textField resignFirstResponder];//取消第一响应者
    
    return YES;
}

#pragma mark - Getters
- (UITextField *)textField{
    if (_textField == nil){
        _textField = [UITextField new];
        _textField.textColor = [UIColor textBlackColor];
        _textField.font = [UIFont titleTextFont];
        _textField.placeholder = @"请输入内容...";
        [_textField addTarget:self action:@selector(action_tapGest:) forControlEvents:UIControlEventAllEvents];
        _textField.returnKeyType = UIKeyboardTypeTwitter;
        _textField.delegate = self;
    }
    return _textField;
}
- (UIImageView *)imageView{
    if (_imageView == nil){
        _imageView = [UIImageView new];
        _imageView.contentMode = UIViewContentModeCenter;
        _imageView.image = [UIImage imageNamed:@"sign_select_more"];
    }
    return _imageView;
}

@end
